﻿using System.Linq;
using Gumini.JulaDB.Engine;
using Gumini.JulaDB.Interfaces;

namespace Gumini.JulaDB.Planner
{
    /// <summary>
    /// Base class for all query plan nodes that have one child node.
    /// </summary>
    internal abstract class UnaryPlanNode : PlanNode
    {
        public UnaryPlanNode(PlanNode child)
            : base(child) { }

        public PlanNode Child
        {
            get { return base.Children.Single(); }
            set
            {
                base.Children.Clear();
                base.Children.Add(value);
            }
        }

        public override IHeading<TemporaryColumn> GetColumns()
        {
            return Child.GetColumns();
        }
    }
}
